package com.vay.de.dang.online.view;

import android.text.InputFilter;
import android.text.Spanned;

public class VnSizeFilter implements InputFilter {

    private int length;

    public VnSizeFilter(int number1) {
        length = number1;
    }

    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {

        // 不能以.开始
        String str = dest.toString();
        if (str.length() == 0 && source != null
                && source.toString().startsWith(".")) {
            return "";
        }

        String input = source != null ? source.toString() : "";
        int len = str.length();
        if (!".".equals(input) && len >= length) {
            return "";
        }

        return null;
    }
}
